home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 May / Macworld (1998-05).dmg / Serious Demos / Lasso 2.5 Test Drive / Lasso 2.5 CGI / Java / DBInfo / GBConstrainer.java < prev    next >
Text File  |  1997-12-12  |  2KB  |  59 lines

  1. import java.awt.*;
  2.  
  3. // not finished. For now, just use the static methods
  4. public class GBConstrainer
  5. {
  6.     protected    Container    mCont = null;
  7.     
  8.     protected GBConstrainer(Container c)
  9.     {    mCont = c;    }
  10.     
  11.     public static void constrain(Container cont, Component component, int grid_y, int grid_x)
  12.     {
  13.         constrain(cont, component, grid_y, grid_x, 1, 1,
  14.                         1, 1, 1, 1, true, GridBagConstraints.NORTHWEST);
  15.     }
  16.     
  17.     public static void constrain(Container cont, Component component, int grid_y, int grid_x,
  18.                         int cell_width, int cell_height, boolean grow)
  19.     {
  20.         constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
  21.                         1, 1, 1, 1, grow, GridBagConstraints.NORTHWEST);
  22.     }
  23.     
  24.     public static void constrain(Container cont, Component component, int grid_y, int grid_x,
  25.                         int cell_width, int cell_height, boolean grow, int wa)
  26.     {
  27.         constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
  28.                         1, 1, 1, 1, grow, wa);
  29.     }
  30.     
  31.     public static void constrain(Container cont, Component component, int grid_y, int grid_x,
  32.                         int cell_width, int cell_height,
  33.                         int top, int left, int bottom, int right, boolean grow)
  34.     {
  35.         constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
  36.                         top, left, bottom, right, grow, GridBagConstraints.NORTHWEST);
  37.     }
  38.     
  39.     public static void constrain(Container cont, Component component, int grid_y, int grid_x,
  40.                         int cell_width, int cell_height,
  41.                         int top, int left, int bottom, int right, boolean grow, int pos)
  42.     {
  43.         GridBagConstraints c =new GridBagConstraints();
  44.         c.gridx = grid_x;
  45.         c.gridy = grid_y;
  46.         c.gridwidth = cell_width;
  47.         c.gridheight = cell_height;
  48.         if (grow)
  49.             c.fill = GridBagConstraints.BOTH;
  50.         else
  51.             c.fill = GridBagConstraints.NONE;
  52.         c.anchor = pos;
  53.         c.weightx = c.weighty = 0.0;
  54.         if (top + left + bottom + right > 0)
  55.             c.insets = new Insets(top, left, bottom, right);
  56.         ((GridBagLayout)cont.getLayout()).setConstraints(component, c);
  57.         cont.add(component);    
  58.     }
  59. }